package com.cn.jinl.controller;

import com.cn.jinl.api.IComplainHandleService;
import com.cn.jinl.domain.ComplainHandle;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import com.cn.jinl.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created On : 2024/1/15.
 * <p>
 * Author : Huiyan
 * <p>
 * Description: ComplainHandleController
 */
@Controller
@RequestMapping("/complain")
public class ComplainHandleController {

    @Autowired
    private IComplainHandleService complainHandleService;


    //query different accept_status
    @RequestMapping("/getComplainHandleList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ComplainHandle>> getComplainHandleList(@RequestBody QueryForm queryForm, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<List<ComplainHandle>> response = new JsonResponse<>();
        List<ComplainHandle> list = complainHandleService.getComplainHandleList(queryForm);
        response.setResult(list);
        response.setSuccess(true);
        return  response;
    }


    @RequestMapping("/addComplainHandle/{frontToken}")
    @ResponseBody
    public JsonResponse<String> addComplainHandle(@RequestBody ComplainHandle complainHandle, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = complainHandleService.addComplainHandle(complainHandle);
        return CommonUtil.getResponseData(response,result);
    }



    @RequestMapping("/updateComplainHandle/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateComplainHandle(@RequestBody ComplainHandle complainHandle, @PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = complainHandleService.updateComplainHandle(complainHandle);
        return CommonUtil.getResponseData(response,result);
    }


    @RequestMapping("/deleteComplainHandle/{frontToken}")
    @ResponseBody
    public JsonResponse<String> deleteComplainHandle(@RequestBody QueryForm queryForm,@PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = complainHandleService.deleteComplainHandle(queryForm);
        return CommonUtil.getResponseData(response,result);
    }



    @RequestMapping("/downloadComplainHandlePDF/{frontToken}")
    @ResponseBody
    public JsonResponse<String> downloadComplainHandlePDF(@RequestBody QueryForm queryForm,@PathVariable(value =  "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = complainHandleService.downloadComplainHandlePDF(queryForm);
        response.setResult(result);
        response.setSuccess(true);
        return response;
    }




}
